<template>
  <div class="Word">
    <div class="flow4">
      <a href="#" onclick="window.external.close();">
        <img
          alt="返回"
          src="/src/assets/images/return.gif"
          border="0"
        />文件列表</a
      >
      <span style="width: 100px"> </span><strong>文档主题：</strong>
      <span style="color: Red">测试文件</span>
    </div>

    <div style="height: 800px; width: auto" v-html="poHtmlCode" />
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "Word",
  data() {
    return {
      poHtmlCode: "",
    };
  },
  created: function () {
    //由于vue中的axios拦截器给请求加token都得是ajax请求，所以这里必须是axios方式去请求后台打开文件的controller
    axios
      .post("/api/TaoHong/Word")
      .then((response) => {
        this.poHtmlCode = response.data;
      })
      .catch(function (err) {
        console.log(err);
      });
  },
  methods: {
    //控件中的一些常用方法都在这里调用，比如保存，打印等等
    Save() {
      pageofficectrl.WebSave();
    },
    //全屏/还原
    IsFullScreen() {
      pageofficectrl.FullScreen = !pageofficectrl.FullScreen;
    },
    OnPageOfficeCtrlInit() {
      // PageOffice的初始化事件回调函数，您可以在这里添加自定义按钮
      pageofficectrl.AddCustomToolButton("保存", "Save", 1);
      pageofficectrl.AddCustomToolButton("全屏/还原", "IsFullScreen", 4);
    },
  },
  mounted: function () {
    // 将vue中的方法赋值给window
    // 以下的为PageOffice事件的回调函数，名称不能改，否则PageOffice控件调用不到
    window.OnPageOfficeCtrlInit = this.OnPageOfficeCtrlInit;
    window.Save = this.Save;
    window.IsFullScreen = this.IsFullScreen;
  },
};
</script>
